﻿using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;

namespace OperationPlugins.Applications.Models
{
    /// <summary>
    /// Defines an application instance.
    /// </summary>
    [Serializable]
    public sealed class AppInstance : MarshalByRefObject, ILogicalThreadAffinative
    {
        /// <summary>
        /// Initializes a new instace of the AppInstance class.
        /// </summary>
        public AppInstance()
        {
            ReferencedAssemblies = new List<ReferenceAssembly>();
            CompositionAssemblies = new List<CompositionAssembly>();
            PayloadContextTypeMappings = new List<PayloadContextTypeMapping>();
            Accounts = new List<Account>();
            Services = new List<Service>();
        }

        /// <summary>
        /// Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// The application id.
        /// </summary>
        public string AppId { get; set; }

        /// <summary>
        /// The application name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// The application version or null if not defined.
        /// </summary>
        public string Version { get; set; }

        /// <summary>
        /// The application configuration data.
        /// </summary>
        public Config Config { get; set; }

        /// <summary>
        /// Referenced assemblies.
        /// </summary>
        public List<ReferenceAssembly> ReferencedAssemblies { get; set; }

        /// <summary>
        /// Composition assemblies.
        /// </summary>
        public List<CompositionAssembly> CompositionAssemblies { get; set; }

        /// <summary>
        /// The payload content type mappings.
        /// See <see cref="HttpRequestHeaders.PayloadContentType"/>.
        /// </summary>
        public List<PayloadContextTypeMapping> PayloadContextTypeMappings { get; set; }

        /// <summary>
        /// Accounts.
        /// </summary>
        public List<Account> Accounts { get; set; }

        /// <summary>
        /// Supported services.
        /// </summary>
        public List<Service> Services { get; set; } 
    }
}
